/*
 * port.h
 *
 *  Created on: 2021年3月1日
 *      Author: root
 */

#ifndef MYOS__HAREWARECOMMUNICATION__PORT_H_
#define MYOS__HAREWARECOMMUNICATION__PORT_H_

#include <common/types.h>

namespace myos{
	namespace hardwarecommunication{

		class Port
		{
			protected:
			myos::common::uint16_t portnumber;   //部件号
				Port(myos::common::uint16_t portnumber);
				~Port();

		};

		class Port8Bit: public Port
		{
			public:
				Port8Bit(myos::common::uint16_t portnumber);
				~Port8Bit();
				virtual void Write(myos::common::uint8_t data);
				virtual myos::common::uint8_t Read();
		};

		class Port8BitSlow: public Port8Bit
		{
			public:
				Port8BitSlow(myos::common::uint16_t portnumber);
				~Port8BitSlow();
				//虚函数,就是抽象函数的意思，只有定义没有实现,不能直接用，必须要被继承,不能直接被实例化
				virtual void Write(myos::common::uint8_t data);
		};

		class Port16Bit: public Port
		{
			public:
				Port16Bit(myos::common::uint16_t portnumber);
				~Port16Bit();
				virtual void Write(myos::common::uint16_t data);
				virtual myos::common::uint16_t Read();
			};

		class Port32Bit: public Port
		{
			public:
				Port32Bit(myos::common::uint16_t portnumber);
				~Port32Bit();
				virtual void Write(myos::common::uint32_t data);
				virtual myos::common::uint32_t Read();
			};
	}
}

#endif /* MYOS__HAREWARECOMMUNICATION__PORT_H_ */
